package com.ruipengkj.view.orderView;

import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JTabbedPane;

import com.ruipengkj.bean.TComment;
import com.ruipengkj.bean.TOrder;
import com.ruipengkj.bean.TUser;
import com.ruipengkj.commons.BuildSpringApplication;
import com.ruipengkj.component.tabbedPane.PerTabbedPaneUI;
import com.ruipengkj.component.tabbedPane.RPTabHeadComponent;
import com.ruipengkj.service.TCommentService;
import com.ruipengkj.service.TOrderService;
import com.ruipengkj.view.base.BasePagePanel;

public class AllPanel extends BasePagePanel<TOrder> implements Runnable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	OrderCommentsPanel orderCommentsPanel;
	OrderAsksPanel orderAsksPanel;	 
	private TOrderService orderService=BuildSpringApplication.getInstance().getTOrderServiceImpl();
	private TCommentService tCommentService=BuildSpringApplication.getInstance().getTCommentServiceImpl();
    public AllPanel() {
    	//TOrderService orderService=BuildSpringApplication.getInstance().getTOrderServiceImpl();
   	 	//TCommentService tCommentService=BuildSpringApplication.getInstance().getTCommentServiceImpl();
   		List <TOrder>orderList = new ArrayList<TOrder>();
       	List <TComment>commentList = new ArrayList<TComment>();
       	TComment tComment = new TComment();
       	tComment.setStatus((byte)10);
       	TOrder torder = new TOrder();
       	TUser tuser= new TUser();
       	tuser.setUserID(null);
       	torder.setTUser(tuser);
       	torder.setTUser(null);
       	torder.setStatus((byte)7);
   		torder.setSource((byte)100);
       	try {
   			orderList=orderService.findService(torder);
   			commentList=tCommentService.findService(tComment);
   		} catch (Exception e) {
   			// TODO Auto-generated catch block
   			e.printStackTrace();
   		}
       	JTabbedPane tabPane = new JTabbedPane();
   		// 设置面板布局为网格布局
   		this.setLayout(new GridLayout(1,1));
   		tabPane.setTabPlacement(JTabbedPane.TOP);// 设定选项卡放在上部
   		this.add(tabPane);// 将选项窗格放置在面板中
   		orderCommentsPanel = new OrderCommentsPanel();
   		orderAsksPanel = new OrderAsksPanel();
   			
   		tabPane.addTab("评论回复("+orderList.size()+")", null,orderCommentsPanel, "评论回复");
   		tabPane.addTab("咨询回复("+commentList.size()+")", null, orderAsksPanel, "咨询回复");

   		tabPane.setUI(new PerTabbedPaneUI(tabPane, 40));
		tabPane.setTabComponentAt(1, new RPTabHeadComponent(tabPane, "评论回复"));
		tabPane.setTabComponentAt(0, new RPTabHeadComponent(tabPane, "咨询回复"));
		tabPane.setBorder(BorderFactory.createTitledBorder(""));
		
   		// 选择第一个选项页为当前选择的选项页
   		tabPane.setSelectedIndex(0);
    }

	@Override
	public void run() {
	 
		orderCommentsPanel.run();
		orderAsksPanel.run();
	}

	@Override
	public void clear() {
		// TODO Auto-generated method stub
		
	}
}